<script type="text/javascript" language="javascript">
var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|]/;
function dodacheck(val) {
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
if(lchar.search(mikExp) != -1) {
var tst = val.value.substring(0, (strLength) - 1);
val.value = tst;
   }
}
function doanothercheck() {
var me=document.getElementById('tf_search');

me.value=me.value.replace(/^\s+|\s+$/g,"");

if(me.value.length < 1) {
alert("Please enter something.");
return false;
}
if(me.value.search(mikExp) == -1) {
return true;
}
else {
alert("Sorry, but the following characters\n\r\n\r@ $ % ^ & * # ( ) [ ] \\ { + } ` ~ =  | \n\r\n\rare not allowed!\n");
me.select();
me.focus();
return false;
}
return true;
}
</script>
<?php
	
	$lvm_category = new CCategory;
	$lvm_type = new CType;
	$lvm_category_detail="";
	
	$lvm_categoryList = $lvm_category -> CCategoryList();
	
	$lvm_stringHTML ='<div class="Ctopleft"></div>
			<h3>SEARCH</h3>
			<div id="search">
			<form action="searchResult.php" name="form" method="post" onsubmit="return doanothercheck(\'tf_search\')">	
            	<input type="text" name="tf_search" id="tf_search" class="search" />
				<input type="submit" class="submit" value="Submit" name="btn_search" />
            </form>
			</div><!-- search -->
			<p>&nbsp;</p>        ';
	
	if(is_array($lvm_categoryList))
	{
		$lvm_stringHTML .=' <ul id="menuhor">';
		/*
		$categoryCount=0;
		foreach( $lvm_categoryList as $key => $value )
		{
			$categoryCount++;
			$lvm_stringHTML.='<img src="./images/c_'.$categoryCount.'.png"/>';
		}*/

		foreach( $lvm_categoryList as $keyCatergory => $valueCategory )
		{
			$lvm_category_detail.=$valueCategory['description']."<br/>";
			
			$lvm_typeList = $lvm_type -> CTypeListOfCategory($valueCategory['id']);
			
			if(is_array($lvm_typeList))					
			{	
				$lvm_stringHTML.= '<li ><a href="#" onclick="loadContent('.$valueCategory['id'].');">'.$valueCategory['name'].'</a><ul>';
				
				
				foreach  ($lvm_typeList as $keyType => $valueType)
				{
					//if($valueType['id_category'] == $valueCategory['id'])
					//{
						$lvm_stringHTML.='<li><a href="products.php?jmp=idb'.$valueType['id'].'&to='.$valueType['name'].'">'.$valueType['name'].'</a></li>';
					//}
				}
			}
			$lvm_stringHTML.= '</ul></li>';		
		}
		
		
		
		$lvm_stringHTML.= '<li><a href="javascript:void(0)">'.$companyname.'</a><ul>';
		//$lvm_stringHTML.='<li><a href="news.php">News</a></li>';
		//$lvm_stringHTML.='<li><a href="">New Products</a></li>';
		$lvm_stringHTML.='<li><a href="products.php">Products</a></li>';
		$lvm_stringHTML.='<li><a href="newproducts.php">New Products</a></li>';
		$lvm_stringHTML.='<li><a href="terms.php">Terms</a></li>';

		$lvm_stringHTML.= '</ul></li>';	

		$lvm_stringHTML .='</ul>';
		//YAHOO CONTACTER
		$lvm_stringHTML.='<div class="DLoldMenu">';
		$lvm_stringHTML.='support online:<br/><br/>';
		$lvm_stringHTML.='<b>Lam Nguyen</b><br/><a href="ymsgr:sendIM?dailamhacker"><img src="http://mail.opi.yahoo.com/online?u=dailamhacker&m=g&t=1"></a><br/>';
		//$lvm_stringHTML.='<a href="http://www.facebook.com/sharer.php?u=.">Share</a>';
		$lvm_stringHTML.='</div>';
		
	}
		echo $lvm_stringHTML;


?>
